﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;

namespace BusinessLogic
{
    public class MainTainRequestCommand : BaseCommand<object>
    {

        public MainTainRequestCommand(string vin, DateTime saledate, string tx_dealer_code,string changefrom, int series_id)  //Create Req
        {
            int TimeZoneDiff = Convert.ToInt32(ConfigurationManager.AppSettings["TimeZoneDiff"].ToString());

            SetQuery("insert into acm_tx (vin,adv_date,tx_status,tx_dealer_code,change_from_dealer_code,car_series_id,change_request_status,change_request_date) values (@vin,@adv_date,@tx_status,@tx_dealer_code,@change_from_dealer_code,@car_series_id,@change_request_status,@change_request_date)");

            cmd.Parameters.AddWithValue("vin", vin);
            cmd.Parameters.AddWithValue("adv_date", saledate);
            cmd.Parameters.AddWithValue("tx_status", "ส่งคำขอแล้ว");
            cmd.Parameters.AddWithValue("tx_dealer_code", tx_dealer_code);
            cmd.Parameters.AddWithValue("change_from_dealer_code", changefrom);
            cmd.Parameters.AddWithValue("car_series_id", series_id);
            cmd.Parameters.AddWithValue("change_request_status", "รอการยืนยัน");
            cmd.Parameters.AddWithValue("change_request_date", DateTime.Now.AddHours(TimeZoneDiff));
        }


        public override void Command()
        {
            Result = cmd.ExecuteNonQuery();
        }

    }
}
